#include "tanobject.h"
#include "tan_boolobject.h"

void Tan_CoreObject_Init()
{
	if (!Tan_true)
		Tan_true = Tan_Bool_fromString("true", 4);
	if (!Tan_false)
		Tan_false = Tan_Bool_fromString("false", 5);
}

TAN_INTERFACE_FUNC(void) Tan_DeleteObject(TanObject* object, Tan_bool force)
{
	TanObject* crtObject = object;
	TanObject* object_next;
	if (force == Tan_true)
	{
		while (crtObject)
		{
			object_next = crtObject->object_set->type_next;
			free(crtObject);
			crtObject = object_next;
		}
	}
	else
	{
		while (crtObject)
		{
			if (((--(Tan_Object_cast(crtObject)->object_usingnb)) == 0))
			{
				object_next = crtObject->object_set->type_next;
				free(crtObject);
				crtObject = object_next;
			}
		}
	}
}

void Tan_SetObjectArg(TanObject* object, TanObject* arg)
{
	assert(object);
	TanObject* cur = object->object_set->type_next;
	while (cur->object_set->type_next != 0) cur = cur->object_set->type_next;
	cur->object_set->type_next = arg;
}
